<%--
  Created by IntelliJ IDEA.
  User: ASUSS
  Date: 2016/8/6
  Time: 14:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>博客列表</title>
    <!--链接BootStrap的css文件-->
    <link rel="stylesheet" type="text/css" href="http://cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css">
    <script type="text/javascript" src="http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
    <script type="text/javascript" src="http://cdn.bootcss.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
    <h1>博客列表</h1>

    <!--如果博客列表为空-->
    <c:if test="${empty blogList}">
        <div class="">
            Blog表为空，请<a href="addblog">添加</a>
        </div>
    </c:if>

    <!--如果博客列表不为空-->
    <c:if test="${!empty blogList}">
        <table>
            <tr>
                <th>ID</th>
                <th>标题</th>
                <th>文章内容</th>
                <th>作者</th>
                <th>发布日期</th>
                <th>操作</th>
            </tr>
            <c:forEach items="${blogList}" var="blog">
                <tr>
                    <td>${blog.id}</td>
                    <td>${blog.title}</td>
                    <td>${blog.content}</td>
                    <td>${blog.userId}</td>
                    <td><fmt:formatDate value="${blog.pubTime}" pattern="yyyy-MM-dd" /></td>
                    <td>
                        <a href="showblog/${blog.id}" type="button" class="btn btn-sm btn-success">详情</a>
                        <a href="updateblog/${blog.id}" type="button" class="btn btn-sm btn-warning">修改</a>
                        <a href="deleteblog/${blog.id}" type="button" class="btn btn-sm btn-danger">删除</a>
                    </td>
                </tr>
            </c:forEach>
        </table>
    </c:if>
    <a href="/blog/">返回首页</a>
</div>
</body>
</html>
